import Vue from "vue";
import Router from "vue-router";
import Category from "../views/Category.vue";
import GoodsList from '../views/GoodsList.vue'
import Cart from "../views/Cart.vue";
import Center from "../views/Center.vue";
import Layout from '../Layout.vue'
// 分类列表页
import ClassificationList from "../views/ClassificationList.vue";
// 详情
import ProductDetails from "../views/ProductDetails.vue"
// 登录
import Login from "../views/Login.vue"
// 注册
import Regester from "../views/Regester.vue"
Vue.use(Router);

export default new Router({
  routes: [
    {
      path: "/",
      component: Layout,
      // 整个app的容器
      children: [
        {
          path: '',
          redirect: "/category", //重定向
        },
        {
          path: "category",
          component: Category,
          children: [
          // 分类列表
          {
          path: '',
          redirect: "/category/11", //重定向
          },
          {
              path: ':id',
              name:'list_id',
              component:ClassificationList,
          }
          ,
          {
              path: ':id/:subCategoryId',
              name:'subCategoryId',
              component: GoodsList
            },
            
          
          ]
        },
        {
              path: '/detail/:id',
              component: ProductDetails
            },
        {
          path: "cart",
          component: Cart,
        },
        {
          path: "center",
          component: Center,
        },
      ],
    },
    // 登录
    {
      path: "/login",
      component: Login
    },
    // 注册
    {
      path: "/regester",
      component: Regester
    },
  ],
  mode: "hash",
  mode: "abstract",
  mode: "history", // pushState
});
